<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sets the response writer used to prepare the response from Solr</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="solrclient.rollback.html">SolrClient::rollback</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="solrclient.setservlet.html">SolrClient::setServlet</a></div>
 <div class="up"><a href="class.solrclient.html">SolrClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="solrclient.setresponsewriter" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SolrClient::setResponseWriter</h1>
  <p class="verinfo">(PECL solr &gt;= 0.9.11)</p><p class="refpurpose"><span class="refname">SolrClient::setResponseWriter</span> &mdash; <span class="dc-title">Sets the response writer used to prepare the response from Solr</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-solrclient.setresponsewriter-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>SolrClient::setResponseWriter</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$responseWriter</code></span>
   )</div>

  <p class="para rdfs-comment">
   Sets the response writer used to prepare the response from Solr
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-solrclient.setresponsewriter-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">responseWriter</code></em></dt>

     <dd>

      <p class="para">One of the following :</p>
      <p class="para">
<div class="parameterscode"><pre class="parameterscode">- xml
 - phpnative</pre>
</div>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-solrclient.setresponsewriter-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
  没有返回值。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-solrclient.setresponsewriter-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4630">
    <p><strong>Example #1 <span class="methodname"><strong>SolrClient::setResponseWriter()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;my&nbsp;custom&nbsp;class&nbsp;for&nbsp;objects<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">SolrClass<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$_properties&nbsp;</span><span style="color: #007700">=&nbsp;array();<br /><br />&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">__get</span><span style="color: #007700">(</span><span style="color: #0000BB">$property_name</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">property_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$property_name</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">$property_name</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;if&nbsp;(isset(</span><span style="color: #0000BB">$_properties</span><span style="color: #007700">[</span><span style="color: #0000BB">$property_name</span><span style="color: #007700">]))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$_properties</span><span style="color: #007700">[</span><span style="color: #0000BB">$property_name</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$options&nbsp;</span><span style="color: #007700">=&nbsp;array<br />(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'hostname'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'port'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">8983</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'path'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'/solr/core1'<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SolrClient</span><span style="color: #007700">(</span><span style="color: #0000BB">$options</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;uses&nbsp;the&nbsp;org.apache.solr.request.PHPNativeResponseWriter&nbsp;class&nbsp;on&nbsp;Solr<br />//&nbsp;Visit&nbsp;the&nbsp;following&nbsp;pages&nbsp;for&nbsp;more&nbsp;details<br />//&nbsp;https://issues.apache.org/jira/browse/SOLR-1967<br />//&nbsp;http://wiki.apache.org/solr/QueryResponseWriter<br />//&nbsp;http://wiki.apache.org/solr/SolPHP<br /></span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setResponseWriter</span><span style="color: #007700">(</span><span style="color: #DD0000">"phpnative"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//$response&nbsp;=&nbsp;$client-&gt;ping();<br /><br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SolrQuery</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setQuery</span><span style="color: #007700">(</span><span style="color: #DD0000">"*:*"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">"objectClassName"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"SolrClass"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">"objectPropertiesStorageMode"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;0&nbsp;for&nbsp;independent&nbsp;properties,&nbsp;1&nbsp;for&nbsp;combined<br /><br /></span><span style="color: #007700">try<br />{<br /><br /></span><span style="color: #0000BB">$response&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$resp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$response</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponse</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$response</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$resp</span><span style="color: #007700">);<br /><br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">);<br /><br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>

</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="solrclient.rollback.html">SolrClient::rollback</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="solrclient.setservlet.html">SolrClient::setServlet</a></div>
 <div class="up"><a href="class.solrclient.html">SolrClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
